<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"                  
                xmlns:f="http://java.sun.com/jsf/core"  
                xmlns:p="http://primefaces.org/ui"
                template="./default_template.xhtml">

    
    <ui:define name="content">
        <f:view>
            <h:form id="form" rendered="#{userController.utilisateur.typeUser == 'Admin'}">   
                <h2><h1><h:outputText value="Compte de : #{userController.USelect.nom}"/></h1></h2>
                <p:dataTable var="item" value="#{userController.lazyComptes}" >  

                    <p:column headerText="Numéro" sortBy="#{item.id}">  
                        <h:outputText value="#{item.id}" />  
                    </p:column>  

                    <p:column headerText="Type" sortBy="#{item.type.libelleType}">  
                        <h:outputText value="#{item.type.libelleType}" />  
                    </p:column>  

                    <p:column headerText="Solde" sortBy="#{item.solde}">  
                        <h:outputText value="#{item.solde} €" />  
                    </p:column>
                    
                    <p:columnGroup type="footer">  
                        <p:row>  
                             <p:column  />
                            <p:column footerText="Total :" style="text-align:right"  />
                            <p:column footerText="#{userController.totalComptes} €" />
                        </p:row>  
                    </p:columnGroup> 
                </p:dataTable>  

                <p:dialog header="Détails compte" widgetVar="compteDialog" resizable="false"  
                        showEffect="explode" hideEffect="explode">  

                    <h:panelGrid id="display" columns="2" cellpadding="4">  

                        <f:facet name="header">  
                            <p:graphicImage value="resouces/img/#{compteMBean.selectC.type.libelleType.trim()}.png"/>  
                        </f:facet>  

                        <h:outputText value="Type Compte :" />  
                        <h:outputText value="#{compteMBean.selectC.type.libelleType}" style="font-weight:bold"/>  

                        <h:outputText value="Solde:" />  
                        <h:outputText value="#{compteMBean.selectC.solde} €" style="font-weight:bold"/>
                    </h:panelGrid>  
                </p:dialog>  

            </h:form>  
            <h:form rendered="#{userController.utilisateur.typeUser == 'Client'}">
                <h1><h:outputText value="Mes comptes"/></h1>
                <p:dataTable value="#{userController.utilisateur.comptes}" var="item" 
                            emptyMessage="No customer found with given criteria" 
                            widgetVar="compteTable"
                            paginator="true"
                            rows="10">
                    <p:column headerText="Id" sortBy="#{item.id}">  
                        <h:outputText value="#{item.id}" />  
                    </p:column> 
                    <p:column id="TypeColumn"  
                            headerText="Type de compte">
                        <h:outputText value="#{item.type.libelleType}"/>
                    </p:column>
                    <p:column id="soldeColumn"
                            headerText="Solde">
                        <h:outputText value="#{item.solde}"/> &euro;
                    </p:column>
                    <p:columnGroup type="footer">  
                        <p:row>
                            <p:column  />
                            <p:column footerText="Total :" style="text-align:right"  />  

                            <p:column footerText="#{userController.total} €" />
                        </p:row>  
                    </p:columnGroup>  
                </p:dataTable>
            </h:form>
        </f:view>
    </ui:define>

</ui:composition>
